<?php
session_start ();
//defined ( 'J_CMS' ) or exit ( 'Access Denied' );
//header ( "Content-Type: text/html; charset=UTF-8" );
$GSelfPath = $_SERVER ['PHP_SELF'];
$GSelfPath = substr ( $GSelfPath, 0, strrpos ( $GSelfPath, '/' ) );
$GSelfPath = substr ( $GSelfPath, 1, strrpos ( $GSelfPath, '/' ) -1 ); //当前路径的上一目录

define ( "SERVER_PORT", $_SERVER ['SERVER_PORT'] ); // 80
$SERVER_PORT = in_array($_SERVER ['SERVER_PORT'],array('80','443'))?'':':'.$_SERVER ['SERVER_PORT'];

if(isset($_SERVER['HTTPS'])){
	define ( "SERVER_NAME", "https://" . $_SERVER ['SERVER_NAME'] . $SERVER_PORT . "/" ); // 得到 https://localhost/
}else{
	define ( "SERVER_NAME", "http://" . $_SERVER ['SERVER_NAME'] . $SERVER_PORT . "/" ); // 得到 http://localhost/
}
//define ( "SERVER_NAME2", "http://" . $_SERVER ['SERVER_NAME'] . $SERVER_PORT . "/" ); // 1.Local, important; 用于生成页面时给的地址
define ( "SERVER_NAME2", "http://" . $_SERVER ['SERVER_NAME'] . "/" ); // 1.Service

$G_LOCALHOST = ($_SERVER ['SERVER_NAME'] == "localhost" || $_SERVER ['SERVER_NAME'] == "127.0.0.1")? true:false;
if($G_LOCALHOST){
	define ( "DOCUMENT_ROOT", $_SERVER['DOCUMENT_ROOT'] . '/'); // D:\www
}else{
	define ( "DOCUMENT_ROOT", $_SERVER['DOCUMENT_ROOT'] . '/' ); // D:\www
}

define ( "PRJ_PATH", $GSelfPath . '/' ); // app/cms/ 得到当前项目的目录 相对于(http://localhost/)
$www_path = split("/",PRJ_PATH);
$www_path = array_slice ($www_path, 0, -2);
$www_path = join("/",$www_path);
$www_path = $www_path == ""?'':$www_path . '/';
define ( "WWW_PATH", $www_path . 'www80/' ); // 静态文件保存位,置相对于(http://localhost/)

//以下以相对 admin 目录为准
define ( "PRJ_ROOT", '../' ); // 相对于程序根目录的位置

// PATH:为程序的相对路径; DIR:为程序要写入的脚本文件; ROOT: ../ 类似目录
define ( "UPLOAD_PATH", WWW_PATH.'upload/' ); //2. Local, important
define ( "UPLOAD_PATH2", 'upload/' ); //2. Service
define ( "HTML_PATH", WWW_PATH.'html/' );	//3. Local, important
define ( "HTML_PATH2", 'html/' );	//3. Service
define ( "PD_PATH", WWW_PATH.'pd/' );	//4. Local, important
define ( "PD_PATH2", 'pd/' );	//4. Service

if($G_LOCALHOST){
	define ( "REL_ROOT", '../../../' ); // 相对于 网站根目录的位置(http://localhost/)
}else{
	define ( "REL_ROOT", '../../' ); // 相对于 网站根目录的位置(http://localhost/)
}
define ( "UPLOAD_DIR", REL_ROOT . UPLOAD_PATH );
define ( "HTML_DIR", REL_ROOT . HTML_PATH );
define ( "PD_DIR", REL_ROOT . PD_PATH );

//	程序:
define ( "LOG_DIR", PRJ_ROOT . 'data/log/' ); // LOG
define ( "YUI_PATH", PRJ_ROOT . 'yui/' ); // YUI
define ( "FCK_PATH", SERVER_NAME . PRJ_PATH . 'FCKeditor/' ); // FCKeditor

//  模版
if($G_LOCALHOST){
	define ( "TPL_ROOT", '../../../' ); // Relative PRJ_PATH
}else{
	define ( "TPL_ROOT", '../../' ); // Relative PRJ_PATH
}
define ( "TPL_PRJ_PATH", '/data/smarty/' ); // TEMPLATES
define ( "TPL_PATH", PRJ_ROOT . 'data/smarty/' ); // TEMPLATES
define ( "TPL_TEM", PRJ_ROOT . 'data/smarty/templates/' ); // TEMPLATES
define ( "LIST_MAIN_VAL", 'mainList' ); //Relative ROOT
define ( "PD_MAIN_PAGE", 'index' ); //Relative ROOT

//echo "<pre>".print_r($_SERVER,true)."</pre>";
//$defined_constants = get_defined_constants(true);
//echo "<pre>".print_r($defined_constants['user'],true)."</pre>";

//	分页符号
define ( "PAGINATION", '<div style="page-break-after: always"><span style="display: none">&nbsp;</span></div>');
//	文章关键字
$ARTICLE_KEY = array("navigation"=>"位置导航","id"=>"文章ID","user_id"=>"编辑ID","user"=>"编辑","title"=>"全标题",
					"title2"=>"短标题","titlePicUrl"=>"标题图片","keyWords"=>"关键字","author"=>"文章作者","from"=>"来源",
					"summary"=>"摘要","content"=>"内容","url"=>"文章链接","redirect"=>"是否重定向","hasPic"=>"有无图片",
					"pageCount"=>"文章页数","sort"=>"排序","state"=>"state","updateTime"=>"更新时间","time"=>"发布时间");

// FCK 
define ( "UPLOAD_DIR_FCK",'www80/upload/' );

//date_default_timezone_set ( 'Asia/Shanghai' );
date_default_timezone_set ( 'Etc/GMT-8' );
?>